package com.hmall.controller;

import com.hmall.common.dto.PageDTO;
import com.hmall.entity.ItemDoc;
import com.hmall.entity.RequestParams;
import com.hmall.service.ItemSearchSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class SearchController {

    @Autowired
    private ItemSearchSerivce itemSearchSerivce;


    /**
     * 关键词搜索
     * @param params
     * @return
     */
    @PostMapping("/search/list")
    public PageDTO<ItemDoc> search(@RequestBody RequestParams params){
        return itemSearchSerivce.search(params);
    }


    /**
     * 获取过滤项
     * @param params
     * @return
     */
    @PostMapping("/search/filters")
    public Map<String, List<String>> filter(@RequestBody  RequestParams params){
        return itemSearchSerivce.filters(params);
    }
}